<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../static/lib/layui-v2.5.5/css/layui.css" media="all">
    <link rel="stylesheet" href="../../static/css/public.css" media="all">
</head>
<body>
<div class="layuimini-container">
    <div class="layuimini-main">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">学号</label>
                    <div class="layui-input-inline">
                        <input type="tel" id="stuId" name="stuId" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <br/>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">姓名</label>
                    <div class="layui-input-inline">
                        <input type="tel" id="stuName" name="stuName" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <br/>
            <div class="layui-form-item">
                <label class="layui-form-label">性别</label>
                <div class="layui-input-block">
                    <input type="radio" id="sex" name="sex" value="0" title="男">
                    <input type="radio" id="sex" name="sex" value="1" title="女">
                </div>
            </div>
            <br/>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">班级</label>
                    <div class="layui-input-inline">
                        <input type="tel" id="className" name="className" lay-verify="required|phone" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <br/>
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">宿舍地址</label>
                    <div class="layui-input-inline">
                        <input type="tel" id="homeName" name="homeName" lay-verify="required|phone" autocomplete="off" class="layui-input">
                    </div>
                </div>
            </div>
            <br/>
            <br/>
        </form>

    </div>
</div>

<script src="../../static/lib/layui-v2.5.5/layui.js" charset="utf-8"></script>
<script>
    layui.use(['form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
			, $ = layui.jquery;



		$(document).ready(
		//获取学生详细信息
			getStudentInfo()
			
		)
		
		function getStudentInfo(){
			$.ajax({
			    type : "get",
			    async:true,
			    url : 'http://localhost:8888/student/getStudentInfo',
			    dataType : "json",
			    xhrFields: { //
			        withCredentials: true,
			    },
			    contentType: 'text/json,charset=utf-8',
			    success : function(resp){
			        studentInfo(resp.data)
			    }
			})
		}
		
		// 回显学生的信息
		function studentInfo(data){
			$("#stuId").val(data.stuId)
			$("#stuName").val(data.stuName)
			$("#className").val(data.className)
			$("#homeName").val(data.homeName)
			// alert(data.sex == 0)
		    $("input[name=sex][value=0]").attr("checked", data.sex == 0 ? true : false);
		    $("input[name=sex][value=1]").attr("checked", data.sex == 1 ? true : false);
			form.render();
		}
    });
</script>
</body>
</html>
